<?php

$installer = $this;
$installer->startSetup();

$installer->run("DROP TABLE IF EXISTS `".$this->getTable('wee_logging/event')."`");
$installer->run("CREATE TABLE `".$this->getTable('wee_logging/event')."` (
  `log_id` int(11) NOT NULL AUTO_INCREMENT,
  `ip` bigint(20) NOT NULL DEFAULT '0',
  `x_forwarded_ip` bigint(20) NOT NULL DEFAULT '0',
  `event_code` varchar(100) NOT NULL DEFAULT '',
  `time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `action` char(20) NOT NULL DEFAULT '-',
  `info` varchar(255) NOT NULL DEFAULT '-',
  `status` char(15) NOT NULL DEFAULT 'success',
  `user` varchar(40) NOT NULL DEFAULT '',
  `user_id` mediumint(9) unsigned DEFAULT NULL,
  `fullaction` varchar(200) NOT NULL DEFAULT '-',
  `error_message` text,
  PRIMARY KEY (`log_id`),
  KEY `FK_LOGGING_EVENT_USER` (`user_id`),
  KEY `IDX_LOGGING_EVENT_USERNAME` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8");

$installer->run("DROP TABLE IF EXISTS `".$this->getTable('wee_logging/event_changes')."`");
$installer->run("CREATE TABLE `".$this->getTable('wee_logging/event_changes')."` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
  `source_name` varchar(150) NOT NULL,
  `event_id` int(11) DEFAULT NULL,
  `source_id` int(11) DEFAULT NULL,
  `original_data` text NOT NULL,
  `result_data` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `event_id` (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8");


$installer->endSetup();
